-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert XLPagerTabStrip to Swift 3 #226
Conversation
buttonBarView.backgroundColor = UIColor(red: 7/255, green: 185/255, blue: 155/255, alpha: 1) | ||
} | ||
|
||
// MARK: - PagerTabStripDataSource | ||
|
||
override func viewControllersForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about changing this signature to viewControllers(forPagerTabStrip: PagerTabStripViewController)
?
} | ||
|
||
// MARK: - IndicatorInfoProvider | ||
|
||
func indicatorInfoForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo { | ||
func indicatorInfoForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indicatorInfo(forPagerTabStrip: PagerTabStripViewController) -> IndicatorInfo
is more close to swift 3 syntax.
@@ -79,7 +79,7 @@ class TableChildExampleViewController: UITableViewController, IndicatorInfoProvi | |||
|
|||
// MARK: - IndicatorInfoProvider | |||
|
|||
func indicatorInfoForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo { | |||
func indicatorInfoForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use for:
instead..
indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInf
override func preferredStatusBarStyle() -> UIStatusBarStyle { | ||
return UIStatusBarStyle.LightContent | ||
override var preferredStatusBarStyle : UIStatusBarStyle { | ||
return UIStatusBarStyle.lightContent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please delete UIStatusBarStyle
override func preferredStatusBarStyle() -> UIStatusBarStyle { | ||
return UIStatusBarStyle.LightContent | ||
override var preferredStatusBarStyle : UIStatusBarStyle { | ||
return UIStatusBarStyle.lightContent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too.
|
||
buttonBarView.selectedBarHeight = settings.style.selectedBarHeight ?? buttonBarView.selectedBarHeight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
buttonBarView.reloadData() | ||
cachedCellWidths = calculateWidths() | ||
buttonBarView.moveToIndex(currentIndex, animated: false, swipeDirection: .None, pagerScroll: .Yes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.moveTo(index: currentIndex, withAnimation: false, swipeDirection: .None, pagerScroll: .Yes)
fatalError("UICollectionViewCell should be or extend from ButtonBarViewCell") | ||
} | ||
let childController = viewControllers[indexPath.item] as! IndicatorInfoProvider | ||
let childController = viewControllers[(indexPath as NSIndexPath).item] as! IndicatorInfoProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not need the casting... indexPath as NSIndexPath
let indicatorInfo = childController.indicatorInfoForPagerTabStrip(self) | ||
|
||
configureCell(cell, indicatorInfo: indicatorInfo) | ||
|
||
if pagerBehaviour.isProgressiveIndicator { | ||
if let changeCurrentIndexProgressive = changeCurrentIndexProgressive { | ||
changeCurrentIndexProgressive(oldCell: currentIndex == indexPath.item ? nil : cell, newCell: currentIndex == indexPath.item ? cell : nil, progressPercentage: 1, changeCurrentIndex: true, animated: false) | ||
changeCurrentIndexProgressive(currentIndex == (indexPath as NSIndexPath).item ? nil : cell, currentIndex == (indexPath as NSIndexPath).item ? cell : nil, 1, true, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would prefer to keep the named parameters in closure variables. Let's check if this is possible
var newContainerViewFrame = self.containerView.frame | ||
newContainerViewFrame.origin.y = buttonBarHeight | ||
newContainerViewFrame.size.height = self.containerView.frame.size.height - (buttonBarHeight - self.containerView.frame.origin.y) | ||
self.containerView.frame = newContainerViewFrame | ||
return buttonBar | ||
}() | ||
|
||
lazy private var cachedCellWidths: [CGFloat]? = { [unowned self] in | ||
lazy fileprivate var cachedCellWidths: [CGFloat]? = { [unowned self] in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may have to use private sometimes. private
means it can be used from the current context.
@@ -63,39 +63,39 @@ public class ButtonBarView: UICollectionView { | |||
addSubview(selectedBar) | |||
} | |||
|
|||
public func moveToIndex(toIndex: Int, animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) { | |||
open func moveToIndex(_ toIndex: Int, animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor signacture
selectedIndex = toIndex | ||
updateSelectedBarPosition(animated, swipeDirection: swipeDirection, pagerScroll: pagerScroll) | ||
} | ||
|
||
public func moveFromIndex(fromIndex: Int, toIndex: Int, progressPercentage: CGFloat,pagerScroll: PagerScroll) { | ||
open func moveFromIndex(_ fromIndex: Int, toIndex: Int, progressPercentage: CGFloat,pagerScroll: PagerScroll) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
@@ -133,24 +133,24 @@ public class ButtonBarView: UICollectionView { | |||
|
|||
// MARK: - Helpers | |||
|
|||
private func updateContentOffset(animated: Bool, pagerScroll: PagerScroll, toFrame: CGRect, toIndex: Int) -> Void { | |||
guard pagerScroll != .No || (pagerScroll != .ScrollOnlyIfOutOfScreen && (toFrame.origin.x < contentOffset.x || toFrame.origin.x >= (contentOffset.x + frame.size.width - contentInset.left))) else { return } | |||
fileprivate func updateContentOffset(_ animated: Bool, pagerScroll: PagerScroll, toFrame: CGRect, toIndex: Int) -> Void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withAnimation:
label.font = UIFont.boldSystemFontOfSize(14.0) | ||
label.autoresizingMask = [.flexibleWidth, .flexibleHeight] | ||
label.textAlignment = .center | ||
label.font = UIFont.boldSystemFont(ofSize: 14.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove UIFont please
@@ -30,66 +30,66 @@ import Foundation | |||
|
|||
public protocol IndicatorInfoProvider { | |||
|
|||
func indicatorInfoForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo | |||
func indicatorInfoForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indicatorInfo(for pagerTabStripController: ......
@@ -30,66 +30,66 @@ import Foundation | |||
|
|||
public protocol IndicatorInfoProvider { | |||
|
|||
func indicatorInfoForPagerTabStrip(pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo | |||
func indicatorInfoForPagerTabStrip(_ pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo | |||
} | |||
|
|||
public protocol PagerTabStripDelegate: class { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this protocol method signatures should be updated!
super.viewDidLayoutSubviews() | ||
updateIfNeeded() | ||
} | ||
|
||
public func moveToViewControllerAtIndex(index: Int, animated: Bool = true) { | ||
guard isViewLoaded() && view.window != nil else { | ||
open func moveToViewControllerAtIndex(_ index: Int, animated: Bool = true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor
No description provided.